---
sidebar_label: Anthropic Tools
sidebar_class_name: hidden
---

:::warning
This API is deprecated as Anthropic now officially supports tools. [Click here to read the documentation](/docs/integrations/chat/anthropic#tools).
:::

# Anthropic Tools

LangChain offers an experimental wrapper around Anthropic that gives it the same API as OpenAI Functions.

## Setup

To start, install the `@langchain/anthropic` integration package.

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/anthropic
```

## Initialize model

You can initialize this wrapper the same way you'd initialize a standard `ChatAnthropic` instance:

import UnifiedModelParamsTooltip from "@mdx_components/unified_model_params_tooltip.mdx";

<UnifiedModelParamsTooltip></UnifiedModelParamsTooltip>

```typescript
import { ChatAnthropicTools } from "@langchain/anthropic/experimental";

const model = new ChatAnthropicTools({
  temperature: 0.1,
  model: "claude-3-sonnet-20240229",
  apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.ANTHROPIC_API_KEY
});
```

## Passing in tools

You can now pass in tools the same way as OpenAI:

import CodeBlock from "@theme/CodeBlock";
import AnthropicToolCalling from "@examples/models/chat/anthropic_tools/tool_calling.ts";

<CodeBlock language="typescript">{AnthropicToolCalling}</CodeBlock>

## Parallel tool calling

The model may choose to call multiple tools. Here is an example using an extraction use-case:

import AnthropicToolCallingExtraction from "@examples/models/chat/anthropic_tools/extraction.ts";

<CodeBlock language="typescript">{AnthropicToolCallingExtraction}</CodeBlock>

## `.withStructuredOutput({ ... })`

:::info
The `.withStructuredOutput` method is in beta. It is actively being worked on, so the API may change.
:::

Using the `.withStructuredOutput` method, you can make the LLM return structured output, given only a Zod or JSON schema:

import WSAExample from "@examples/models/chat/integration_anthropic_tools_wsa.ts";

<CodeBlock language="typescript">{WSAExample}</CodeBlock>

### Using JSON schema:

import WSAJSONExample from "@examples/models/chat/integration_anthropic_tools_wsa_json.ts";

<CodeBlock language="typescript">{WSAJSONExample}</CodeBlock>
